libxenctrl headers should not pollute macro namespace with
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 12 Feb 2008 11:37:45 +0000 (11:37 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 12 Feb 2008 11:37:45 +0000 (11:37 +0000)
mb/rmb/wmb. Instead add a xen_ prefix. Modify Xen's public headers to
expect the prefixed names instead of bare mb/rmb/wmb, but gate this
expectation on a bump of __XEN_INTERFACE_VERSION__.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
12 files changed:
tools/blktap/drivers/tapdisk.c
tools/console/daemon/io.c
tools/fs-back/fs-backend.c
tools/ioemu/hw/xen_console.c
tools/ioemu/hw/xenfb.c
tools/ioemu/target-i386-dm/helper2.c
tools/libxc/xenctrl.h
tools/xenmon/xenbaked.c
tools/xenstore/xenstored_domain.c
tools/xentrace/xentrace.c
xen/include/public/io/ring.h
xen/include/public/xen-compat.h

index 993e09b155b06d792c8fe071c6fd85057f9486bf..75f06c701ca1e76f470d1ea196b75824bdf805e2 100644 (file)
@@ -641,7 +641,7 @@ static void get_io_request(struct td_state *s)
        if (!run) return; /*We have received signal to close*/
 
        rp = info->fe_ring.sring->req_prod; 
-       rmb();
+       xen_rmb();
        for (j = info->fe_ring.req_cons; j != rp; j++)
        {
                int done = 0, start_seg = 0; 
index 52df19ed34cfd7bb665bc38edc2ab0bae8a97569..9573333c08e45fdd18a5824608e68d4f3c4daf2d 100644 (file)
@@ -153,7 +153,7 @@ static void buffer_append(struct domain *dom)
 
        cons = intf->out_cons;
        prod = intf->out_prod;
-       mb();
+       xen_mb();
 
        size = prod - cons;
        if ((size == 0) || (size > sizeof(intf->out)))
@@ -172,7 +172,7 @@ static void buffer_append(struct domain *dom)
                buffer->data[buffer->size++] = intf->out[
                        MASK_XENCONS_IDX(cons++, intf->out)];
 
-       mb();
+       xen_mb();
        intf->out_cons = cons;
        xc_evtchn_notify(dom->xce_handle, dom->local_port);
 
@@ -750,7 +750,7 @@ static int ring_free_bytes(struct domain *dom)
 
        cons = intf->in_cons;
        prod = intf->in_prod;
-       mb();
+       xen_mb();
 
        space = prod - cons;
        if (space > sizeof(intf->in))
@@ -797,7 +797,7 @@ static void handle_tty_read(struct domain *dom)
                        intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
                                msg[i];
                }
-               wmb();
+               xen_wmb();
                intf->in_prod = prod;
                xc_evtchn_notify(dom->xce_handle, dom->local_port);
        } else {
index 634d5fa31ec5f3f7a404149ec356643ded3c3b2d..fd5ba2b46ba05d8c3de199a55cc928ad19a7a117 100644 (file)
@@ -140,8 +140,8 @@ void* handle_mount(void *data)
         handle_aio_events(mount);
 moretodo:
         rp = mount->ring.sring->req_prod;
-        rmb(); /* Ensure we see queued requests up to 'rp'. */
-                
+        xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
+
         while ((cons = mount->ring.req_cons) != rp)
         {
             int i;
index 76aca8f3ee1e08d95347235d192c9018f8085bc8..44f8bcca4833d82eaa98bda5cea8371c7bde9de3 100644 (file)
@@ -75,7 +75,7 @@ static void buffer_append(struct domain *dom)
 
        cons = intf->out_cons;
        prod = intf->out_prod;
-       mb();
+       xen_mb();
 
        size = prod - cons;
        if ((size == 0) || (size > sizeof(intf->out)))
@@ -94,7 +94,7 @@ static void buffer_append(struct domain *dom)
                buffer->data[buffer->size++] = intf->out[
                        MASK_XENCONS_IDX(cons++, intf->out)];
 
-       mb();
+       xen_mb();
        intf->out_cons = cons;
        xc_evtchn_notify(dom->xce_handle, dom->local_port);
 
@@ -289,7 +289,7 @@ static int ring_free_bytes(struct domain *dom)
 
        cons = intf->in_cons;
        prod = intf->in_prod;
-       mb();
+       xen_mb();
 
        space = prod - cons;
        if (space > sizeof(intf->in))
@@ -322,7 +322,7 @@ static void xencons_receive(void *opaque, const uint8_t *buf, int len)
                intf->in[MASK_XENCONS_IDX(prod++, intf->in)] =
                        buf[i];
        }
-       wmb();
+       xen_wmb();
        intf->in_prod = prod;
        xc_evtchn_notify(dom->xce_handle, dom->local_port);
 }
index f0d7f7936ef50d02dedaa5e3a990dc1554f08865..54189861788e7d073f27658eac668b7fc19d0f18 100644 (file)
@@ -485,7 +485,7 @@ static void xenfb_on_fb_event(struct xenfb *xenfb)
        prod = page->out_prod;
        if (prod == page->out_cons)
                return;
-       rmb();                  /* ensure we see ring contents up to prod */
+       xen_rmb();              /* ensure we see ring contents up to prod */
        for (cons = page->out_cons; cons != prod; cons++) {
                union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
                int x, y, w, h;
@@ -512,7 +512,7 @@ static void xenfb_on_fb_event(struct xenfb *xenfb)
                        break;
                }
        }
-       mb();                   /* ensure we're done with ring contents */
+       xen_mb();               /* ensure we're done with ring contents */
        page->out_cons = cons;
        xc_evtchn_notify(xenfb->evt_xch, xenfb->fb.port);
 }
@@ -571,9 +571,9 @@ static int xenfb_kbd_event(struct xenfb *xenfb,
                return -1;
        }
 
-       mb();                   /* ensure ring space available */
+       xen_mb();               /* ensure ring space available */
        XENKBD_IN_RING_REF(page, prod) = *event;
-       wmb();                  /* ensure ring contents visible */
+       xen_wmb();              /* ensure ring contents visible */
        page->in_prod = prod + 1;
        return xc_evtchn_notify(xenfb->evt_xch, xenfb->kbd.port);
 }
index d45ac7a999f69676698a5b525ff8042eb1c4c44a..4896b11ab834a3fafdcb0e7e44f66d3a338913ca 100644 (file)
@@ -218,7 +218,7 @@ static ioreq_t *__cpu_get_ioreq(int vcpu)
         return NULL;
     }
 
-    rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
+    xen_rmb(); /* see IOREQ_READY /then/ read contents of ioreq */
 
     req->state = STATE_IOREQ_INPROCESS;
     return req;
@@ -568,7 +568,7 @@ void __handle_buffered_iopage(CPUState *env)
 
         __handle_ioreq(env, &req);
 
-        mb();
+        xen_mb();
         buffered_io_page->read_pointer += qw ? 2 : 1;
     }
 }
@@ -603,7 +603,7 @@ void cpu_handle_ioreq(void *opaque)
             return;
         }
 
-        wmb(); /* Update ioreq contents /then/ update state. */
+        xen_wmb(); /* Update ioreq contents /then/ update state. */
 
        /*
          * We do this before we send the response so that the tools
index b9e9abd249821070b4574da4c24deafe8e2bc56a..afc80a36dfb09a9da214e5f62b3e03aab2f0a137 100644 (file)
  */
 
 #if defined(__i386__)
-#define mb()  __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#define xen_mb()  asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define xen_rmb() asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define xen_wmb() asm volatile ( "" : : : "memory")
 #elif defined(__x86_64__)
-#define mb()  __asm__ __volatile__ ( "mfence" : : : "memory")
-#define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
-#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#define xen_mb()  asm volatile ( "mfence" : : : "memory")
+#define xen_rmb() asm volatile ( "lfence" : : : "memory")
+#define xen_wmb() asm volatile ( "" : : : "memory")
 #elif defined(__ia64__)
-#define mb()   __asm__ __volatile__ ("mf" ::: "memory")
-#define rmb()  __asm__ __volatile__ ("mf" ::: "memory")
-#define wmb()  __asm__ __volatile__ ("mf" ::: "memory")
+#define xen_mb()   asm volatile ("mf" ::: "memory")
+#define xen_rmb()  asm volatile ("mf" ::: "memory")
+#define xen_wmb()  asm volatile ("mf" ::: "memory")
 #elif defined(__powerpc__)
-/* XXX loosen these up later */
-#define mb()   __asm__ __volatile__ ("sync" : : : "memory")
-#define rmb()  __asm__ __volatile__ ("sync" : : : "memory") /* lwsync? */
-#define wmb()  __asm__ __volatile__ ("sync" : : : "memory") /* eieio? */
+#define xen_mb()   asm volatile ("sync" : : : "memory")
+#define xen_rmb()  asm volatile ("sync" : : : "memory") /* lwsync? */
+#define xen_wmb()  asm volatile ("sync" : : : "memory") /* eieio? */
 #else
 #error "Define barriers"
 #endif
index 728f14b7530f9a7e761d45417fa0148606a45341..32ca9f36c343a6358d25877585666f7ef0016c1d 100644 (file)
@@ -511,10 +511,10 @@ int monitor_tbufs(void)
         {
             while ( meta[i]->cons != meta[i]->prod )
             {
-                rmb(); /* read prod, then read item. */
+                xen_rmb(); /* read prod, then read item. */
                 rec_size = process_record(
                     i, (struct t_rec *)(data[i] + meta[i]->cons % data_size));
-                mb(); /* read item, then update cons. */
+                xen_mb(); /* read item, then update cons. */
                 meta[i]->cons += rec_size;
             }
         }
index 2cc9881eb45477b5c207036b7b06af40b77f3453..d1d59f9f6f5ed9040bb759ef1b1687e81c01a68a 100644 (file)
@@ -112,7 +112,7 @@ static int writechn(struct connection *conn,
        /* Must read indexes once, and before anything else, and verified. */
        cons = intf->rsp_cons;
        prod = intf->rsp_prod;
-       mb();
+       xen_mb();
 
        if (!check_indexes(cons, prod)) {
                errno = EIO;
@@ -124,7 +124,7 @@ static int writechn(struct connection *conn,
                len = avail;
 
        memcpy(dest, data, len);
-       mb();
+       xen_mb();
        intf->rsp_prod += len;
 
        xc_evtchn_notify(xce_handle, conn->domain->port);
@@ -142,7 +142,7 @@ static int readchn(struct connection *conn, void *data, unsigned int len)
        /* Must read indexes once, and before anything else, and verified. */
        cons = intf->req_cons;
        prod = intf->req_prod;
-       mb();
+       xen_mb();
 
        if (!check_indexes(cons, prod)) {
                errno = EIO;
@@ -154,7 +154,7 @@ static int readchn(struct connection *conn, void *data, unsigned int len)
                len = avail;
 
        memcpy(data, src, len);
-       mb();
+       xen_mb();
        intf->req_cons += len;
 
        xc_evtchn_notify(xce_handle, conn->domain->port);
index 0879576645e93c385597dbe4af8bbcfe746545b3..7f394d2af090fa6c65d38410007493a1598739f1 100644 (file)
@@ -384,8 +384,8 @@ int monitor_tbufs(int outfd)
             /* Read window information only once. */
             cons = meta[i]->cons;
             prod = meta[i]->prod;
-            rmb(); /* read prod, then read item. */
-            
+            xen_rmb(); /* read prod, then read item. */
+
             if ( cons == prod )
                 continue;
            
@@ -428,7 +428,7 @@ int monitor_tbufs(int outfd)
                              outfd);
             }
 
-            mb(); /* read buffer, then update cons. */
+            xen_mb(); /* read buffer, then update cons. */
             meta[i]->cons = prod;
         }
 
index 355eba55452935785534cc3b1bfc7be1dbead478..6ce1d0d485fc884824be4951fcc23be9d6d8dafe 100644 (file)
 #ifndef __XEN_PUBLIC_IO_RING_H__
 #define __XEN_PUBLIC_IO_RING_H__
 
+#include "../xen-compat.h"
+
+#if __XEN_INTERFACE_VERSION__ < 0x00030208
+#define xen_mb()  mb()
+#define xen_rmb() rmb()
+#define xen_wmb() wmb()
+#endif
+
 typedef unsigned int RING_IDX;
 
 /* Round a 32-bit unsigned constant down to the nearest power of two. */
@@ -211,12 +219,12 @@ typedef struct __name##_back_ring __name##_back_ring_t
     (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
 
 #define RING_PUSH_REQUESTS(_r) do {                                     \
-    wmb(); /* back sees requests /before/ updated producer index */     \
+    xen_wmb(); /* back sees requests /before/ updated producer index */ \
     (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
 } while (0)
 
 #define RING_PUSH_RESPONSES(_r) do {                                    \
-    wmb(); /* front sees responses /before/ updated producer index */   \
+    xen_wmb(); /* front sees resps /before/ updated producer index */   \
     (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt;                         \
 } while (0)
 
@@ -253,9 +261,9 @@ typedef struct __name##_back_ring __name##_back_ring_t
 #define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do {           \
     RING_IDX __old = (_r)->sring->req_prod;                             \
     RING_IDX __new = (_r)->req_prod_pvt;                                \
-    wmb(); /* back sees requests /before/ updated producer index */     \
+    xen_wmb(); /* back sees requests /before/ updated producer index */ \
     (_r)->sring->req_prod = __new;                                      \
-    mb(); /* back sees new requests /before/ we check req_event */      \
+    xen_mb(); /* back sees new requests /before/ we check req_event */  \
     (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) <           \
                  (RING_IDX)(__new - __old));                            \
 } while (0)
@@ -263,9 +271,9 @@ typedef struct __name##_back_ring __name##_back_ring_t
 #define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do {          \
     RING_IDX __old = (_r)->sring->rsp_prod;                             \
     RING_IDX __new = (_r)->rsp_prod_pvt;                                \
-    wmb(); /* front sees responses /before/ updated producer index */   \
+    xen_wmb(); /* front sees resps /before/ updated producer index */   \
     (_r)->sring->rsp_prod = __new;                                      \
-    mb(); /* front sees new responses /before/ we check rsp_event */    \
+    xen_mb(); /* front sees new resps /before/ we check rsp_event */    \
     (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) <           \
                  (RING_IDX)(__new - __old));                            \
 } while (0)
@@ -274,7 +282,7 @@ typedef struct __name##_back_ring __name##_back_ring_t
     (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
     if (_work_to_do) break;                                             \
     (_r)->sring->req_event = (_r)->req_cons + 1;                        \
-    mb();                                                               \
+    xen_mb();                                                           \
     (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r);                   \
 } while (0)
 
@@ -282,7 +290,7 @@ typedef struct __name##_back_ring __name##_back_ring_t
     (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
     if (_work_to_do) break;                                             \
     (_r)->sring->rsp_event = (_r)->rsp_cons + 1;                        \
-    mb();                                                               \
+    xen_mb();                                                           \
     (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r);                  \
 } while (0)
 
index c9f369f0e948089ceafc56a4aeae08867543aadc..c2894990cd0e7cb2cf5416f3098db7958511b1a1 100644 (file)
@@ -27,7 +27,7 @@
 #ifndef __XEN_PUBLIC_XEN_COMPAT_H__
 #define __XEN_PUBLIC_XEN_COMPAT_H__
 
-#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030207
+#define __XEN_LATEST_INTERFACE_VERSION__ 0x00030208
 
 #if defined(__XEN__) || defined(__XEN_TOOLS__)
 /* Xen is built with matching headers and implements the latest interface. */